package com.junzhiit.nengji.app.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.app.service.HomeService;
import com.junzhiit.nengji.app.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/home")
public class HomeController extends BaseController{
	
	@Autowired
	private HomeService homeService;
	
	@ApiOperation(value="取得商家的统计数据(全部交易额、总付款订单数、昨日交易额、昨日付款单数)")
	@RequestMapping(value="/header",method=RequestMethod.GET)
	public ResultVO getheaderInfo(String sessionId){
		AssertUtil.notBlank(sessionId, "sessionId is required.");
		return homeService.getheaderInfo(sessionId);
	}
	
	@ApiOperation(value="取得商家销售统计")
	@RequestMapping(value="/orders",method=RequestMethod.GET)
	public ResultVO queryOrdersInfo(String sessionId,Integer year,Integer month){
		return homeService.queryOrdersInfo(sessionId,year,month);
	}
	
	@ApiOperation(value="取得商家指定月销售统计")
	@RequestMapping(value="/goods",method=RequestMethod.GET)
	public ResultVO queryForGoods(String sessionId,int month){
		AssertUtil.notBlank(sessionId, "sessionId is required.");
		AssertUtil.notNull(month, "month is required.");
		return homeService.queryForGoods(sessionId, month);
	}
	
	@ApiOperation(value="取得系统通知")
	@RequestMapping(value="/notice",method=RequestMethod.GET)
	public ResultVO queryInternalNotice(){
		return homeService.queryInternalNotice();
	}
	
	@ApiOperation(value="取得店铺通知")
	@RequestMapping(value="/shop/notice",method=RequestMethod.GET)
	public ResultVO queryInternalShopNotice(){
		return homeService.queryInternalShopNotice();
	}
	
	@ApiOperation(value="统计该店铺下各个状态下的有效订单数量")
	@RequestMapping(value="/count/status",method=RequestMethod.GET)
	public ResultVO countOrdersStatus(String sessionId){
		AssertUtil.notBlank(sessionId, "sessionId is required.");
		return homeService.countOrdersStatus(sessionId);
	}
	
}
